Socket
Socket
Sign inDemoInstall

@peculiar/asn1-rsa

Package Overview
Dependencies
4
Maintainers
6
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peculiar/asn1-rsa


Version published
Maintainers
6
Install size
1.11 MB
Created

Package description

What is @peculiar/asn1-rsa?

@peculiar/asn1-rsa is an npm package that provides ASN.1 schema definitions for RSA cryptographic algorithms. It is useful for encoding and decoding RSA keys and signatures in ASN.1 format, which is a standard interface for representing cryptographic data.

What are @peculiar/asn1-rsa's main functionalities?

Encoding RSA Public Key

This code demonstrates how to encode an RSA public key into ASN.1 format using the @peculiar/asn1-rsa package.

const { RSAPublicKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');

const publicKey = new RSAPublicKey({
  modulus: new Uint8Array([0x00, 0x01, 0x02, 0x03]),
  publicExponent: new Uint8Array([0x01, 0x00, 0x01])
});

const asn1PublicKey = AsnConvert.serialize(publicKey);
console.log(asn1PublicKey);

Decoding RSA Public Key

This code demonstrates how to decode an ASN.1 encoded RSA public key using the @peculiar/asn1-rsa package.

const { RSAPublicKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');

const asn1PublicKey = new Uint8Array([/* ASN.1 encoded public key bytes */]);
const publicKey = AsnConvert.parse(asn1PublicKey, RSAPublicKey);
console.log(publicKey);

Encoding RSA Private Key

This code demonstrates how to encode an RSA private key into ASN.1 format using the @peculiar/asn1-rsa package.

const { RSAPrivateKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');

const privateKey = new RSAPrivateKey({
  version: 0,
  modulus: new Uint8Array([0x00, 0x01, 0x02, 0x03]),
  publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
  privateExponent: new Uint8Array([0x00, 0x01, 0x02, 0x03]),
  prime1: new Uint8Array([0x00, 0x01]),
  prime2: new Uint8Array([0x00, 0x01]),
  exponent1: new Uint8Array([0x00, 0x01]),
  exponent2: new Uint8Array([0x00, 0x01]),
  coefficient: new Uint8Array([0x00, 0x01])
});

const asn1PrivateKey = AsnConvert.serialize(privateKey);
console.log(asn1PrivateKey);

Decoding RSA Private Key

This code demonstrates how to decode an ASN.1 encoded RSA private key using the @peculiar/asn1-rsa package.

const { RSAPrivateKey } = require('@peculiar/asn1-rsa');
const { AsnConvert } = require('@peculiar/asn1-schema');

const asn1PrivateKey = new Uint8Array([/* ASN.1 encoded private key bytes */]);
const privateKey = AsnConvert.parse(asn1PrivateKey, RSAPrivateKey);
console.log(privateKey);

Other packages similar to @peculiar/asn1-rsa

Readme

Source

@peculiar/asn1-rsa

License npm version

NPM

RFC 8017 RSA Cryptography Specifications Version 2.2

Keywords

FAQs

Last updated on 17 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc